package utils.io;

import impl.myjdkimpl.MyInvocationHandler;

import java.io.*;
import java.lang.reflect.Method;

/**
 * Created by chenjun on 2017/11/21.
 */
public class FileUtils {

    public  static  byte[] copyToByteArray(File file){
        byte[] bytes  = null;
        InputStream inputStream = null;
        try {
            inputStream = new FileInputStream(file);
            bytes = new byte[inputStream.available()];
            inputStream.read(bytes);
        }catch (IOException ioe){
            ioe.printStackTrace();
        }finally {
            try {
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return  bytes;
    }

    public  static  void copy(String stringifyJavaClass,File file) {
        try {
            if(file.exists() ==false) {
                file.createNewFile();
            }
            FileOutputStream outputStream = new FileOutputStream(file);
            outputStream.write(stringifyJavaClass.getBytes());
            outputStream.flush();
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}


